from datetime import date


class Cabinet:
    def __init__(self, id: int = None, name: str = None):
        self.id = id
        self.name = name

    def __iter__(self):
        yield 'id', self.id
        yield 'name', self.name

    def to_row(self):
        return str(self.id), self.name


class Direction:
    def __init__(self, id: int = None, name: str = None):
        self.id = id
        self.name = name

    def __iter__(self):
        yield 'id', self.id
        yield 'name', self.name

    def to_row(self):
        return str(self.id), self.name


class Laborant:
    def __init__(self, id: int = None, second_name: str = None):
        self.id = id
        self.second_name = second_name

    def __iter__(self):
        yield 'id', self.id
        yield 'second_name', self.second_name

    def to_row(self):
        return str(self.id), str(self.second_name)


class Student:
    def __init__(self, id: int = None, name: str = None, direction: Direction = None):
        self.id = id
        self.name = name
        self.direction = direction

    def __iter__(self):
        yield 'id', self.id,
        yield 'name', self.name
        yield 'direction_id', self.direction.id

    def to_row(self):
        return str(self.id), str(self.name), str(self.direction.name)


class Entry:
    def __init__(self, id: int = None, cabinet: Cabinet = None, student: Student = None, laborant: Laborant = None,
                 comp_num: int = None, lesson_num: int = None, lesson_date: date = None):
        self.id = id
        self.student = student
        self.cabinet = cabinet
        self.laborant = laborant
        self.lesson_date = lesson_date
        self.lesson_num = lesson_num
        self.comp_num = comp_num

    def __iter__(self):
        yield 'id', self.id
        yield 'student_id', self.student.id
        yield 'cabinet_id', self.cabinet.id
        yield 'laborant_id', self.laborant.id
        yield 'lesson_date', self.lesson_date
        yield 'lesson_num', self.lesson_num
        yield 'comp_num', self.comp_num

    def to_row(self):
        return (str(self.id), str(self.lesson_num), str(self.comp_num), str(self.student.name), str(self.lesson_date),
                str(self.laborant.second_name), str(self.cabinet.name))


class Page:
    def __init__(self, content: list, page: int, total_pages: int, size: int):
        self.size = size
        self.total_pages = total_pages
        self.page = page
        self.content = content
